package com.gift.util;

import com.gift.common.Constant;
import com.gift.vo.R;

/**
 * Created by levy on 2018/2/9.
 */
public class RUtils {
    private static final String SUCCESS_MSG = "成功";
    private static final Integer SUCCESS_CODE = 1;


    /**
     * http回调成功
     *
     * @param object
     * @return
     */
    public static R success(Object object) {
        R r = new R();
        r.setCode(SUCCESS_CODE);
        r.setMsg(SUCCESS_MSG);
        r.setData(object);
        return r;
    }

    /**
     * 无object返回
     *
     * @return
     */
    public static R success() {
        return success(null);
    }

    /**
     * http回调错误  --异常
     *
     * @param
     * @param msg
     * @return
     */
    public static R error(String msg) {
        R r = new R();
        r.setCode(Constant.HTTP_RES_ERROR);
        r.setMsg(msg);
        r.setData(null);
        return r;
    }


    public static R faith(String msg) {
        R r = new R();
        r.setCode(Constant.HTTP_RES_FAITH);
        r.setMsg(msg);
        r.setData(null);
        return r;
    }

}
